package reflect;

import com.google.common.collect.Lists;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.beanutils.PropertyUtils;
import org.junit.Test;

import java.beans.PropertyDescriptor;
import java.lang.reflect.InvocationTargetException;
import java.util.List;

public class TestAll {

    @Test
    public void testPropertyUtil() throws IllegalAccessException, NoSuchMethodException, InvocationTargetException {
        TestEntity entity = TestEntity.builder().id(1L)
                .name("fkkkk")
                .list(Lists.newArrayList(1, 2, 3))
                .build();

        PropertyDescriptor[] propertyDescriptors = PropertyUtils.getPropertyDescriptors(entity);
        for (PropertyDescriptor descriptor : propertyDescriptors) {
            System.out.println(descriptor.getName());
            System.out.println(descriptor.getPropertyType());
            System.out.println("-----------------------------");
        }
    }

}



@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
class TestEntity {

    private Long id;
    private String name;
    private List<Integer> list;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public List<Integer> getList() {
        return list;
    }

    public void setList(List<Integer> list) {
        this.list = list;
    }
}
